/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.StructuredActivities;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.FundamentalActivities.ActivityNode;
import edu.pku.sei.modeler.model.uml.FundamentalActivities.ActivityNode;
import edu.pku.sei.modeler.model.uml.BasicActions.OutputPin;
import edu.pku.sei.modeler.model.uml.BasicActions.OutputPin;
import edu.pku.sei.modeler.model.uml.BasicActions.InputPin;
import edu.pku.sei.modeler.model.uml.BasicActions.OutputPin;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;


/**
 * @generated
 *
 */
public class LoopNode extends StructuredActivityNode implements ILoopNode {
	// attributes
	
	protected boolean isTestedFirst;
	
	
	
	
	// references
	
	protected MetaTypedList setupPart;
	
	protected MetaTypedList bodyPart;
	
	protected MetaTypedList decider;
	
	protected MetaTypedList result;
	
	protected MetaTypedList loopVariableInput;
	
	protected MetaTypedList bodyOutput;
	
	
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "LOOPNODE_ISTESTEDFIRST",
			catalog = "Model",
			name = ModelPackage.LOOPNODE_ISTESTEDFIRST,
			setter = "setisTestedFirst"
			)
	
	public boolean getIsTestedFirst() {
		return isTestedFirst;
	}
	public void setIsTestedFirst(boolean newIsTestedFirst) {
		boolean oldisTestedFirst = isTestedFirst;
		isTestedFirst = newIsTestedFirst;
		firePropertyChange(ModelPackage.LOOPNODE_ISTESTEDFIRST, oldisTestedFirst, newIsTestedFirst);
	}
	
	// getters for references
	
	public MetaTypedList getSetupPart() {
		if(setupPart == null) {
			setupPart = new MetaTypedList(ActivityNode.class, this, ModelPackage.LOOPNODE_SETUPPART);
		}
		return setupPart;
	}
	
	public MetaTypedList getBodyPart() {
		if(bodyPart == null) {
			bodyPart = new MetaTypedList(ActivityNode.class, this, ModelPackage.LOOPNODE_BODYPART);
		}
		return bodyPart;
	}
	
	public MetaTypedList getDecider() {
		if(decider == null) {
			decider = new MetaTypedList(OutputPin.class, this, ModelPackage.LOOPNODE_DECIDER);
		}
		return decider;
	}
	
	public MetaTypedList getResult() {
		if(result == null) {
			result = new MetaTypedList(OutputPin.class, this, ModelPackage.LOOPNODE_RESULT);
		}
		return result;
	}
	
	public MetaTypedList getLoopVariableInput() {
		if(loopVariableInput == null) {
			loopVariableInput = new MetaTypedList(InputPin.class, this, ModelPackage.LOOPNODE_LOOPVARIABLEINPUT);
		}
		return loopVariableInput;
	}
	
	public MetaTypedList getBodyOutput() {
		if(bodyOutput == null) {
			bodyOutput = new MetaTypedList(OutputPin.class, this, ModelPackage.LOOPNODE_BODYOUTPUT);
		}
		return bodyOutput;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.LOOPNODE_ISTESTEDFIRST, isTestedFirst);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_SETUPPART, setupPart);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_BODYPART, bodyPart);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_DECIDER, decider);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_RESULT, result);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_LOOPVARIABLEINPUT, loopVariableInput);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.LOOPNODE_BODYOUTPUT, bodyOutput);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isTestedFirst = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.LOOPNODE_ISTESTEDFIRST);
		
		// references
		
		this.getSetupPart().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_SETUPPART, this));
		
		this.getBodyPart().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_BODYPART, this));
		
		this.getDecider().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_DECIDER, this));
		
		this.getResult().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_RESULT, this));
		
		this.getLoopVariableInput().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_LOOPVARIABLEINPUT, this));
		
		this.getBodyOutput().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.LOOPNODE_BODYOUTPUT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.LOOPNODE_SETUPPART.equals(featureID)) {
			getSetupPart().add(value);
		}
		
		else if(ModelPackage.LOOPNODE_BODYPART.equals(featureID)) {
			getBodyPart().add(value);
		}
		
		else if(ModelPackage.LOOPNODE_DECIDER.equals(featureID)) {
			getDecider().add(value);
		}
		
		else if(ModelPackage.LOOPNODE_RESULT.equals(featureID)) {
			getResult().add(value);
		}
		
		else if(ModelPackage.LOOPNODE_LOOPVARIABLEINPUT.equals(featureID)) {
			getLoopVariableInput().add(value);
		}
		
		else if(ModelPackage.LOOPNODE_BODYOUTPUT.equals(featureID)) {
			getBodyOutput().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 